'use strict';
/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller } = app;
  /**
   * 上传文件
   */
  router.post('/api/upload/file', controller.upload.file);

  /**
   * 用户权限相关
   */
  router.post('/api/user/login', controller.user.login);
  router.post('/api/user/register', controller.user.register);
  router.put('/api/user/updatePassword', controller.user.updatePassword);
  router.post('/api/user/updateUserRoles', controller.user.updateUserRoles);
  router.get('/api/user/getUserRoles', controller.user.getUserRoles);
  router.get('/api/user/getUserInfo', controller.user.getUserInfo);
  router.resources('user', '/api/user', controller.user);
  // 角色
  router.get('/api/role/list', controller.role.allList);
  router.resources('role', '/api/role', controller.role);
  // 菜单
  router.get('/api/menu/list', controller.menu.allList);
  router.resources('menu', '/api/menu', controller.menu);

  /**
   * 物流管理系统相关路由
   */
  // 快递网点管理
  router.get('/api/expressOutlet/list', controller.expressOutlet.allList);
  router.resources('expressOutlet', '/api/expressOutlet', controller.expressOutlet);

  // 物流仓库管理
  router.get('/api/warehouse/list', controller.warehouse.allList);
  router.resources('warehouse', '/api/warehouse', controller.warehouse);

  // 物流公司管理
  router.get('/api/logisticsCompany/list', controller.logisticsCompany.allList);
  router.resources('logisticsCompany', '/api/logisticsCompany', controller.logisticsCompany);

  // 物品分类管理
  router.get('/api/itemCategory/list', controller.itemCategory.allList);
  router.resources('itemCategory', '/api/itemCategory', controller.itemCategory);

  // 物品管理
  router.get('/api/item/list', controller.item.allList);
  router.resources('item', '/api/item', controller.item);

  // 保险公司管理
  router.get('/api/insuranceCompany/list', controller.insuranceCompany.allList);
  router.resources('insuranceCompany', '/api/insuranceCompany', controller.insuranceCompany);

  // 保险保额管理
  router.get('/api/insuranceCoverage/list', controller.insuranceCoverage.allList);
  router.resources('insuranceCoverage', '/api/insuranceCoverage', controller.insuranceCoverage);

  // 快递订单管理
  router.get('/api/expressOrder/list', controller.expressOrder.allList);
  router.post('/api/expressOrder/createOrder', controller.expressOrder.createOrder);
  router.post('/api/expressOrder/updateStatus', controller.expressOrder.updateStatus);
  router.get('/api/expressOrder/getUserOrders', controller.expressOrder.getUserOrders);
  router.get('/api/expressOrder/getTrackInfo', controller.expressOrder.getTrackInfo);
  router.resources('expressOrder', '/api/expressOrder', controller.expressOrder);

  // 物流轨迹管理
  router.get('/api/logisticsTrack/list', controller.logisticsTrack.allList);
  router.post('/api/logisticsTrack/addTrack', controller.logisticsTrack.addTrack);
  router.resources('logisticsTrack', '/api/logisticsTrack', controller.logisticsTrack);

  // 系统公告管理
  router.get('/api/announcement/list', controller.announcement.allList);
  router.get('/api/announcement/getActiveAnnouncements', controller.announcement.getActiveAnnouncements);
  router.resources('announcement', '/api/announcement', controller.announcement);
};
